import axios, {AxiosInstance} from 'axios';
import qs from 'qs';

// 配置新建一个 axios 实例
const service: AxiosInstance = axios.create({
    baseURL: 'https://vivo.zhongwangyingtong.com',
    timeout: 50000,
    headers: {'Content-Type': 'multipart/form-data'},
    paramsSerializer: {
        serialize(params) {
            return qs.stringify(params, {allowDots: true});
        },
    },
});

// 添加请求拦截器
service.interceptors.request.use(
    (config) => {
        return config;
    },
    (error) => {
        // 对请求错误做些什么
        return Promise.reject(error);
    }
);

// 导出 axios 实例
export default service;
